package com.xsd.awen.web;

import com.xsd.awen.config.WebResult;
import com.xsd.awen.domain.entity.Project;
import com.xsd.awen.domain.vo.ProjectVo;
import com.xsd.awen.service.ProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("project")
public class ProjectController {

    @Autowired
    ProjectService projectService;

    @PostMapping("page")
    public String page(ProjectVo projectVo){
        return WebResult.page(projectService.page(projectVo));
    }

    @PostMapping("add")
    public String add(Project project){
        return projectService.save(project);
    }

    @PostMapping("update")
    public String update(Project project){
        return projectService.update(project);
    }

    @PostMapping("delete")
    public String delete(Project project){
        return projectService.delete(project);
    }

    @PostMapping("get")
    public String get(Project project){
        return WebResult.OK(projectService.getById(project.getId()));
    }

}